package com.tencent.ncnnyolox.net

import com.tencent.ncnnyolox.basemodule.base.BaseViewModel
import com.tencent.ncnnyolox.basemodule.event.SingleLiveEvent
import com.tencent.ncnnyolox.net.bean.ChatPhraseAddDTO
import com.tencent.ncnnyolox.net.bean.ChatPhraseUpdateDTO
import com.tencent.ncnnyolox.net.bean.CommonWordBean
import com.tencent.ncnnyolox.net.bean.PhraseLabelBean
import com.tencent.ncnnyolox.net.bean.request.ChatHistoryAddDTO
import com.tencent.ncnnyolox.net.bean.request.ChatHistoryRequest
import com.tencent.ncnnyolox.net.bean.response.ChatHistoryResponse
import com.yd.basemodule.base.bean.BaseResult

/**
 * <pre>
 *     author : yh
 *     e-mail : xxx@xx
 *     time   : 2023/12/22
 *     desc   :
 * </pre>
 */
 class ApiViewModel:BaseViewModel() {


    private val Api by lazy {
        ApiNetWork.getInstance()
    }
    /**
     * 获取用户聊天常用
      */
    private val commonData=SingleLiveEvent<BaseResult<List<CommonWordBean>>>()
    fun getCommonWord(id:String):SingleLiveEvent<BaseResult<List<CommonWordBean>>>{
        launchUI {
            commonData.value=Api.getCommonWord(id)
        }

        return commonData
    }

    /**
     * 修改聊天常用语
     */
    private val  updateCommonData=SingleLiveEvent<BaseResult<String>>()
    fun  updateCommonWord(bean:ChatPhraseUpdateDTO):SingleLiveEvent<BaseResult<String>>{
        launchUI {
            updateCommonData.value=Api.updateCommonWord(bean)
        }
        return updateCommonData
    }

    /**
     * 添加聊天常用语
     */
    private val addCommonData=SingleLiveEvent<BaseResult<String>>()
    fun addCommonWord(bean:ChatPhraseAddDTO):SingleLiveEvent<BaseResult<String>>{
        launchUI {
            addCommonData.value=Api.addCommonWord(bean)
        }
        return addCommonData
    }

    /**
     * 删除聊天常用语
     */
    private val deleteCommonData=SingleLiveEvent<BaseResult<String>>()
    fun deleteCommonData(id:Long):SingleLiveEvent<BaseResult<String>>{
        launchUI {
            deleteCommonData.value=Api.deleteCommonWord(id)
        }
        return deleteCommonData
    }

    /**
     * 获取常用语标签
     */
    private val  phraseLabelData=SingleLiveEvent<BaseResult<List<PhraseLabelBean>>>()
    fun  getPhraseLabel():SingleLiveEvent<BaseResult<List<PhraseLabelBean>>>{
        launchUI {
            phraseLabelData.value=Api.getLabelPhrase()
        }
        return phraseLabelData
    }


    /**
     * 获取聊天记录
     */
    private val  chatRecorData=SingleLiveEvent<BaseResult<List<ChatHistoryResponse>>>()
    fun getChatRecord(bean:ChatHistoryRequest):SingleLiveEvent<BaseResult<List<ChatHistoryResponse>>>{
        launchUI {
            chatRecorData.value=Api.getChatResponseRecord(bean)
        }
        return chatRecorData
    }

    /**
     * 添加聊天记录
     */

    private val addRecordData=SingleLiveEvent<BaseResult<String>>()
    fun addRecord(bean:ChatHistoryAddDTO):SingleLiveEvent<BaseResult<String>>{
        launchUI {
            addRecordData.value=Api.addRecord(bean)
        }
        return addRecordData
    }



}